/**
 * @see [微信官方文档](https://mp.weixin.qq.com/debug/wxadoc/dev/api/bluetooth.html#wxreadblecharacteristicvalueobject)
 * @param deviceId [string] 蓝牙设备 id
 * @param serviceId [string] 蓝牙特征值对应服务的 uuid
 * @param characteristicId [string] 蓝牙特征值的 uuid
 */

export default function read_ble_characteristic_value(deviceId: string, serviceId: string, characteristicId: string) {
	return new Promise<{
		characteristic: {
			/**
			 * 蓝牙设备特征值的 uuid
			 */
			characteristicId: string;
			/**
			 * 蓝牙设备特征值对应服务的 uuid
			 */
			serviceId: string;
			/**
			 * 蓝牙设备特征值对应的二进制值
			 */
			value: ArrayBuffer;
		};
	}>((resolve, reject) => {
		wx.readBLECharacteristicValue({
			characteristicId,
			deviceId,
			serviceId,
			success(res) {
				resolve(res);
			},
			fail() {
				reject(false);
			}
		});
	});
}
